package fr.expdev.bndd.data;

import java.util.List;

import fr.expdev.bndd.Main;
import fr.expdev.bndd.PostView;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

public class PostAdapter extends BaseAdapter {
	
	private Main _main;
	private List<Post> _posts;

	public PostAdapter(Main main, List<Post> posts) {
		super();
		_main = main;
		_posts = posts;
	}
	
	public void setPosts(List<Post> posts) {
		_posts = posts;
	}

	@Override
	public int getCount() {
		return _posts.size();
	}

	@Override
	public Object getItem(int position) {
		return _posts.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		return new PostView(_main, _posts.get(position));
	}

}
